package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ParkingRecordGate;
import com.ruoyi.service.IParkingRecordGateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 远程开闸记录Controller
 * 
 * @author dongdong
 * @date 2025-08-30
 */
@RestController
@RequestMapping("/parking/recordGate")
public class ParkingRecordGateController extends BaseController
{
    @Autowired
    private IParkingRecordGateService parkingRecordGateService;

    /**
     * 查询远程开闸记录列表
     */
    @PreAuthorize("@ss.hasPermi('parking:recordGate:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkingRecordGate parkingRecordGate)
    {
        startPage();
        List<ParkingRecordGate> list = parkingRecordGateService.selectParkingRecordGateList(parkingRecordGate);
        return getDataTable(list);
    }

    /**
     * 导出远程开闸记录列表
     */
    @PreAuthorize("@ss.hasPermi('parking:recordGate:export')")
    @Log(title = "远程开闸记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkingRecordGate parkingRecordGate)
    {
        List<ParkingRecordGate> list = parkingRecordGateService.selectParkingRecordGateList(parkingRecordGate);
        ExcelUtil<ParkingRecordGate> util = new ExcelUtil<ParkingRecordGate>(ParkingRecordGate.class);
        util.exportExcel(response, list, "远程开闸记录数据");
    }

    /**
     * 获取远程开闸记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('parking:recordGate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(parkingRecordGateService.selectParkingRecordGateById(id));
    }

    /**
     * 新增远程开闸记录
     */
    @PreAuthorize("@ss.hasPermi('parking:recordGate:add')")
    @Log(title = "远程开闸记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkingRecordGate parkingRecordGate)
    {
        return toAjax(parkingRecordGateService.insertParkingRecordGate(parkingRecordGate));
    }

    /**
     * 修改远程开闸记录
     */
    @PreAuthorize("@ss.hasPermi('parking:recordGate:edit')")
    @Log(title = "远程开闸记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkingRecordGate parkingRecordGate)
    {
        return toAjax(parkingRecordGateService.updateParkingRecordGate(parkingRecordGate));
    }

    /**
     * 删除远程开闸记录
     */
    @PreAuthorize("@ss.hasPermi('parking:recordGate:remove')")
    @Log(title = "远程开闸记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkingRecordGateService.deleteParkingRecordGateByIds(ids));
    }
}
